#ifndef _VSOCKET_H_
#define _VSOCKET_H_
#include <sys/types.h>
#include <netdb.h>
//#include "../../common/info_cont.h"



// linux socket class
class vsock_t
{
public:
    typedef int32_t socket_t;

private:
    socket_t __sock;

    // low-lvl functions
    void send(const void *data, const size_t length) const;
    void recv(void *data, const size_t length) const;

public:
    vsock_t(socket_t sock = 0);

    // for send int types
    template <class numeric_type>
    inline void send_numeric(const numeric_type data) const
    {
        send(&data, sizeof(numeric_type));
    }

    // for recv int types
    template <class numeric_type>
    inline numeric_type recv_numeric() const
    {
        numeric_type data = 0;
        recv(&data, sizeof(numeric_type));
        return data;
    }

    void send_char(const char *data) const;
    char* recv_char() const;

    int operator=(const int);
    operator int()
    {
        return __sock;
    }
};

#endif
